
import React, {Fragment} from "react";
import {Button} from "antd";

class FormatFile extends React.Component{
    constructor(props) {
        super(props);
        this.state = {}
    }

    render() {
        try {
            let files = JSON.parse(this.props.record);
            return (
                <Fragment>
                    {Array.isArray(files) && files.map((item,index) => {
                        if (item.hasOwnProperty("url")){
                            return (
                                <Fragment key={index}>
                                    <Button style={{padding:1}} type={"link"} target={"block"} href={item["url"]}>{item["name"]}</Button>
                                </Fragment>
                            )
                        }else {
                            return "无效的文件";
                        }
                    })}
                </Fragment>
            );
        }catch (e) {
            return "无效的文件";
        }
    }
}

export default FormatFile;
